﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BartonExtension;
using Model;

namespace Backend
{
    public partial class CellEditor : DevExpress.XtraEditors.XtraForm
    {
        public StoreCatalog sc { get; set; }
        public DialogResult result { get; set; }
        public CellEditor()
        {
            InitializeComponent();
        }

        public CellEditor(StoreCatalog s_c)
        {

            InitializeComponent();
            sc = s_c;
            toggleFeature.IsOn = sc.isFeatured;
            spinTP.EditValue = sc.top_price;
            spinLP.EditValue = sc.low_price;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            float tp_ = spinTP.EditValue.toFloat().Value;
            float lp_ = spinLP.EditValue.toFloat().Value;
            if(tp_ < lp_)
            {
                XtraMessageBox.Show("Invalid price");
                return;
            }
            sc.top_price = tp_;
            sc.low_price = lp_;
            sc.isFeatured = toggleFeature.IsOn;

            result = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
        private void btnCancel_Click(object sender, EventArgs e)
        {
            result = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        } 
    }
}